package com.base.api.cdr;

import com.base.api.pms.PmsPublicSqlQuery;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;
import java.util.Map;

/**
 * @author wnhuang
 * @Package com.base.api.cdr
 * @date 2021-1-1 22:50
 */
@Component
public class OperationAnesthesia extends PmsPublicSqlQuery {

    @Override
    public String splicSql(String sql, Map<String, Object> param) {
        StringBuilder param1 = new StringBuilder();
        if (param != null) {
            if (param.get("patientId") != null && !StringUtils.isBlank((String) (param.get("patientId")))) {
                param1.append(" and C.patient_id ='" + param.get("patientId") + "'");
            }
            if (param.get("visitNumber") != null && !StringUtils.isBlank((String) (param.get("visitNumber")))) {
                param1.append(" and pai_visit_id ='" + param.get("visitNumber") + "'");
            }
        }
        return MessageFormat.format(sql.replace("'", "''"), param1.toString());
    }
}
